VS Code 运行生成任务(Run Build Task):以g++编译一个C++程序为例 |
您所在的位置:网站首页 › vs code 只编译不运行 › VS Code 运行生成任务(Run Build Task):以g++编译一个C++程序为例 |
添加一个任务步骤如下: 一、点击终端中运行生成任务 二、首次运行,需要配置生成任务 三、选择用模板创建 tasks.json 文件 四、选择 Others 运行任意外部命令的示例 五、创建 tasks.json 成功,编辑之本本以用 g++ 编译 hello.cpp 为例,将 tasks.json 配置如下: { // See https://go.microsoft.com/fwlink/?LinkId=733558 // for the documentation about the tasks.json format "version": "2.0.0", "tasks": [ { "label": "build", // 取个名字 "type": "shell", "command": "g++ -g hello.cpp -o hello", // 执行的命令 "group": { // 从这里 "kind": "build", "isDefault": true }, // 到这里,设置为默认构建任务,按Ctrl+Shift+B立即执行,不必选择 "problemMatcher": "$gcc"// 问题匹配程序 } ] }编辑保存,按 Ctrl+Shift+B 执行结果如下图: 软件版本: Visual Studio Code 1.30.1GCC 8.2.0参考资料: C++Now 2018: Rong Lu “C++ Development with Visual Studio Code”define task as the default build task源码下载(包含调试 launch.json) |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |